require "sketchup.rb"

$Aimages目录 = File.join($DC目录, "images")
$Ahtml目录 = File.join($DC目录, "html")
$SKPS目录 = File.join($DC目录, "skps")

# def $AreloadDC(clear_console = true, undo = false)
#   verbose = $VERBOSE
#   $VERBOSE = nil
#   puts "load file: #{File.join($DC目录, "**/*.{rb,rbe}")}"
#   Dir.glob(File.join($DC目录, "**/*.{rb,rbe}")).each { |file|
#     # puts "load file: "+file
#     load(file)
#   }
#   puts "dc~" * 108
#   # UI.start_timer(0) { SKETCHUP_CONSOLE.clear } if clear_console
# ensure
#   $VERBOSE = verbose
#   nil
# end

$AreloadDC = lambda do |clear_console = true, undo = false|
  verbose = $VERBOSE
  $VERBOSE = nil
  $dc_observers = nil

  model = Sketchup.active_model
  unless model.nil?
    puts "移除 Observer   ……ing👇"
    model.tools.remove_observer(
      $ADCToolsObserver
    )
    model.selection.remove_observer(
      $ADCSelectionObserver
    )
    model.remove_observer(
      $ADCModelObserver
    )
    model.definitions.remove_observer(
      $ADCDefinitionsObserver
    )
  end
  # file = File.join($DC目录, "ruby/dcobservers.rb")
  # puts "file 👉 #{file}"
  # load(file)
  # puts "__FILE__ 👉 #{__FILE__}"
  # load(__FILE__)
  # puts "load file: #{File.join($DC目录, "**/*.{rb,rbe}")}"
  Dir.glob(File.join($DC目录, "**/*.{rb,rbe}")).each { |file|
    # puts "load file 👉 #{file}"
    load(file)
  }
  puts "dc~" * 108
  # $dc_observers = DCObservers.new()
ensure
  $VERBOSE = verbose
  nil
end

Sketchup::require "su_dynamiccomponents/ruby/dcobservers"
